package com.finesys.backend.common.utils;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: CopyRight (c) 2020-2035</p>
 * <p>Company: finesys Co. LTD.</p>
 * <p>Author: lehoon</p>
 * <p>Date: 2021/4/6 14:31</p>
 */
public final class ServiceUtils {

    /**
     * 根据字符串返回服务类型byte
     * @param serverType
     * @return
     */
    public static Byte getServerType(String serverType){
        byte serviceType = 0;
        if(serverType !=null && !"".equals(serverType)){
            if(serverType.equals("java")){
                serviceType = 1;
            }else if(serverType.equals("tomcat")){
                serviceType = 0;
            }else if(serverType.equals("interface")){
                serviceType = 2;
            }else if(serverType.equals("apama")){
                serviceType = 4;
            }
        }
        return serviceType;
    }

    /**
     * 是否允许部署
     * @param state
     * @return
     */
    public static boolean isCanDeploy(final String state) {
        if (state == null || state.length() == 0) {
            return true;
        }

        if ("0".equals(state)) {
            return true;
        }

        return false;
    }

    /**
     * 是否允许取消部署
     * @param state
     * @return
     */
    public static boolean isCanUnDeploy(final String state) {
        if (state == null || state.length() == 0) {
            return false;
        }

        if ("1".equals(state)) {
            return true;
        }

        return false;
    }
}
